using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class StartViewEvent : ButtonPanel
{
    public ButtonPanel chooseChartPanel;
    public GameObject AboutWindow;
    public GameObject SettingPanel;
    public GameObject Logo;

    private List<Vector2Int> posOfButton;
    private List<Vector2Int> posOfHideButton;

    protected override void InitializeEvent()
    {
        if (posOfButton == null || posOfButton.Count <= 0)
        {
            posOfButton = new List<Vector2Int>
            {
                new Vector2Int(0, 1),
                new Vector2Int(1, 1),
                new Vector2Int(2, 1),
                new Vector2Int(2, 0),
                new Vector2Int(2,2)
            };

            posOfHideButton = new List<Vector2Int>
            {
                new Vector2Int(0,0),
                new Vector2Int(0,2),
                new Vector2Int(1,0),
                new Vector2Int(1,2)
            };
        }
        

        buttonManager.ChangeText(posOfButton[0], "Start");
        buttonManager.ChangeText(posOfButton[1], "About");
        buttonManager.ChangeText(posOfButton[2], "Exit");
        buttonManager.ChangeText(posOfButton[3], "Setting");
        buttonManager.ChangeText(posOfButton[4], "ChartEditor");

        buttonManager.ChangeOnClickEvent(posOfButton[0], StartEvent);
        buttonManager.ChangeOnClickEvent(posOfButton[1], AboutEvent);
        buttonManager.ChangeOnClickEvent(posOfButton[2], ExitEvent);
        buttonManager.ChangeOnClickEvent(posOfButton[3], SettingEvent);
        buttonManager.ChangeOnClickEvent(posOfButton[4], ChartEditorEvent);

        buttonManager.HideButton(posOfHideButton);

        Logo.SetActive(true);
    }

    public void StartEvent()
    {
        Logo.SetActive(false);
        chooseChartPanel.InitializeButtonPanel();
    }

    public void AboutEvent()
    {
        if (AboutWindow == null)
            return;
        AboutWindow.SetActive(!AboutWindow.activeSelf);
    }

    public void ExitEvent()
    {
        Application.Quit();
    }

    public void SettingEvent()
    {
        if (SettingPanel == null)
            return;
        SettingPanel.SetActive(!SettingPanel.activeSelf);
    }

    public void ChartEditorEvent()
    {
        Debug.Log("TODO");
        // todo!
    }
}
